<?php
/**
 * Username Rule
 * Validates usernames
 *
 * @package     Visi
 * @subpackage  Rules
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2010 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id$
 */
class Visi_Rule_Username extends Q_Rule_Abstract {

    /**
     * The parameters that were passed to this rule
     */
    protected $_params = array(
        'min' => 3,
        'max' => 15,
    );
    
    public function isValid($value) {
    
        $min = $this->getParam('min');
        $max = $this->getParam('max');
        $pattern = '/^[a-z0-9]{' . $min . ',' . $max . '}$/i';
        return preg_match($pattern, $value);
    
    }

}
